home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 012 / keys.lqr / keys.lbr / keyfile.c < prev    next >
Text File  |  2011-02-04  |  1KB  |  52 lines

  1. /* Creates header file keys.new with macros for recognizing special IBM keys */
  2.  
  3. /*                    Courtesy of Dr. Bob's Utilities    1985                */
  4.  
  5.  
  6. #include f:defs.h
  7. #include f:stdio.h
  8.  
  9.  
  10. main()
  11. {
  12.  
  13.     int c;
  14.     char temp[20];
  15.     FILE *fp, *fopen();
  16.  
  17.  
  18.     printf("\n\nKEYFILE    --   creates macro file KEYS.NEW to help\n");
  19.     printf("recognize IBM 'special' keys.\n\nMerge into your KEYS.H file.\n");
  20.     printf("Use with key.c (contains inch() and kb() functions).\n");
  21.     printf("\n\nCourtesy of Dr. Bob's Utilities - 1985\n\n");
  22.  
  23.  
  24.  
  25.  
  26. fp = fopen("keys.new","w");   /* open keys.new for writing */
  27.     for(;;) {
  28.         printf("\n-------------------------\nEnter macro ('q' to quit): ");
  29.         gets(temp);
  30.         if ((*temp == 'q') || (*temp == 'Q'))  {
  31.                  fclose(fp);
  32.                  exit();
  33.              }
  34.         printf("Press key macro refers to: ");
  35.         c = inch();
  36.         fprintf(fp,"#define %s  %d\n",temp,c);  /* write line to keys.new file */
  37.  
  38.      }
  39.  
  40. }
  41.  
  42. inch()  /* waits for & returns char from kb as int ascii value */
  43. {
  44.     int c;
  45.  
  46.     while ((c = kb()) == 0)   /* wait for keypress  */
  47.               ;
  48.  
  49.              return(c);       /* return it          */
  50. }
  51.  
  52.